Skip to content

Fix unbounded inflate parsing binary fragments#76

Merged
bluekeyes merged 1 commit into
masterfrom
fix-unbounded-inflate
Jul 18, 2026
Merged

Fix unbounded inflate parsing binary fragments#76
bluekeyes merged 1 commit into
masterfrom
fix-unbounded-inflate

Conversation

@bluekeyes

Copy link
Copy Markdown
Owner

When parsing a binary fragment, the library attempted to decompress the patch data before checking the expected size and without specifying any limit. This allowed a malicious patch to include an "inflate bomb" as a binary fragment, forcing the library to allocate excessive memory during parsing.

The BinaryFragment type now stores the raw compressed data at parse time and provides a separate method to get a reader for the decompressed data. The reader limits the decompressed size to the declared size in the fragment. This is an API break, but I expect very few clients interact with binary fragment data directly.

This fixes the unbounded inflate during parsing and also limits the memory allocated by the library during an apply to a copy buffer. However, applying a patch can still write large amounts of data to the client-provided writer in ways the client can't easily prevent. A future commit will enforce limits at apply time to fix this.

When parsing a binary fragment, the library attempted to decompress the
patch data before checking the expected size and without specifying any
limit. This allowed a malicious patch to include an "inflate bomb" as a
binary fragment, forcing the library to allocate excessive memory during
parsing.

The BinaryFragment type now stores the raw compressed data at parse time
and provides a separate method to get a reader for the decompressed
data. The reader limits the decompressed size to the declared size in
the fragment. This is an API break, but I expect very few clients
interact with binary fragment data directly.

This fixes the unbounded inflate during parsing and also limits the
memory allocated by the library during an apply to a copy buffer.
However, applying a patch can still write large amounts of data to the
client-provided writer in ways the client can't easily prevent. A future
commit will enforce limits at apply time to fix this.
@bluekeyes
bluekeyes merged commit 61f6dcb into master Jul 18, 2026
1 check passed
@bluekeyes
bluekeyes deleted the fix-unbounded-inflate branch July 18, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant